Before we can write any programs we need to get to grips with some low level stuff which configures how the C source files that you are going to create are actually made into programs which will control what the PIC microcontroller hardware does. This is kind of unpleasant, in that we need to delve down to a level which you may not be happy with if you have not used the command prompt before. However, the good news is that we only have to do this once, and when you have the settings in place you can get on with writing and running your programs using the windows based tools.
The process of getting your wonderful programs into the PIC is a three stage one:
- First compile the C source file using the MPLAB XC8 compiler to produce an object output file
- Then use a linker program (also part of XC8) to combine the object files and produce a binary code file
- Then use a programmer program (PPP / mLoader) to program this binary code into the PIC we are using.
Once the program has been sent to the PIC microcontroller it is held in it's memory even if the power is turned off. This program will run automatically each time the PIC microcontroller is turned on. We can of course change the program for another one at any time by simply re-programming it.